<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sitemesh" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>

<div class="panel_container">
    <div class="panel">
        <form id="formId" method="post" action="${ctx}/entrustedLoan/addEntrustedLoan">
            <div class="panel_header">
                <div><h2>添加委托贷款</h2></div>
            </div>
            <div class="panel_body">
                <div>
                    <div>
                        <div class="info_item"><span>委托人组织机构代码:</span><b>*</b>
                           <input type="text" name="wtrzzjgdm" />
                        </div>

                        <div class="info_item"><span>借款人组织结构代码:</span><b>*</b>
                            <input type="text" name="jkrzzjgdm" />
                        </div>

                        <div class="info_item"><span>金融机构编码:</span><b>*</b>
                            <select name="orgId" id="orgId">
                                <option value="">--请选择--</option>
                                <c:forEach var="entry" items="${orgList}">
                                    <option value="${entry.id}" >${entry.orgName}</option>
                                </c:forEach>
                            </select>
                        </div>

                    </div>

                    <div>
                        <div class="info_item"><span>数据时间:</span><b>*</b>
                            <input type="text" name="sjsj" id="sjsj"  />
                        </div>

                        <div class="info_item"><span>币种:</span><b>*</b>
                            <tags:select name="bz" id="bz" tableName="T_SYSTEM_DICT" whereClause="CODE_TYPE_ID = 9 "  />
                        </div>

                        <div class="info_item"><span>利率(%):</span><b>*</b>
                            <input type="text" name="ll" />
                        </div>
                    </div>

                    <div>
                        <div class="info_item"><span>业务发生额:</span><b>*</b>
                            <input type="text" name="ywfse"  />
                        </div>

                        <div class="info_item"><span>业务余额:</span><b>*</b>
                            <input type="text" name="ywye" />
                        </div>

                        <div class="info_item"><span>贷款发放日期:</span><b>*</b>
                            <input type="text" name="dkffrq" id="dkffrq" />
                        </div>

                    </div>

                    <div>
                        <div class="info_item"><span>客户名称:</span><b>*</b>
                            <input type="text" name="qymc" id="qymc"  />
                        </div>

                        <div class="info_item"><span>借据号码:</span><b>*</b>
                            <input type="text" name="jjh" id="jjh"  />
                        </div>

                        <div class="info_item"><span>贷款到期日期:</span><b>*</b>
                            <input type="text" name="dkdqrq" id="dkdqrq"  />
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel_footer">
                <div>
                    <input type="submit" value="保存" class="btn_blue" id="btn_save"/>
                    <input type="button" value="返回" class="btn_blue" id="btn_back"/>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">

    function goBack(){
        linkTo("${ctx}/entrustedLoan/toEntrustedLoan");
    }

    $(function () {

        $('#sjsj').datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'yymm'
        });
        $('#dkffrq').datepicker();
        $('#dkdqrq').datepicker();

        $("#btn_back").bind("click",goBack);

        $("#formId").validate({
            rules:{
                wtrzzjgdm: "required",
                jkrzzjgdm: "required",
                sjsj: "required",
                bz: "required",
                ll:{
                    required:true,
                    number:true,
                    min:0,
                    max:99.9999
                },
                ywfse:{
                    required:true,
                    number:true,
                    min:0,
                    max:9999999999999.99
                },
                ywye:{
                    required:true,
                    number:true,
                    min:0,
                    max:9999999999999.99
                },
                dkffrq: "required",
                dkdqrq: "required"
            },
            messages:{
                wtrzzjgdm: "委托人组织机构代码不能为空",
                jkrzzjgdm: "借款人组织结构代码不能为空",
                sjsj: "数据时间不能为空",
                bz: "币种不能为空",
                ll:{
                    number:"必须是数字",
                    required:"利率不能为空",
                    min:"最小值0",
                    max:"最大值99.9999"
                },
                ywfse:{
                    number:"必须是数字",
                    required:"业务发生额不能为空",
                    min:"最小值0",
                    max:"最大值9999999999999.99"
                },
                ywye:{
                    number:"必须是数字",
                    required:"业务余额不能为空",
                    min:"最小值0",
                    max:"最大值9999999999999.99"
                },
                dkffrq: "贷款发放日期不能为空",
                dkdqrq: "贷款到期日期不能为空"

            },
            submitHandler: function(form) {
                $(form).ajaxSubmit({
                    success: function(response) {
                        $.prompt("保存成功");
                        window.setTimeout(function(){
                            goBack();
                        },2000);
                    },

                    error: function(response){
                        $.prompt("保存失败:"+response,"错误");
                    }
                });
            }
        });
    });

</script>

